package com.cqupt.slewing.room

import androidx.lifecycle.LiveData
import androidx.room.*

@Dao
interface ItemDao {
    @Query("SELECT * FROM item ORDER BY ID DESC")
    fun getAllItemsLive(): LiveData<List<Item>>

    @Query("SELECT * FROM item WHERE id IN (:Ids)")
    fun loadAllByIds(Ids: IntArray): List<Item>

    @Query("SELECT * FROM item WHERE id = :id")
    fun findByID(id: Int): Item

    @Query("SELECT * FROM item WHERE macID LIKE :macID LIMIT 1")
    fun findByMac(macID: String): Item

    @Insert
    fun insertItems(vararg items: Item)

    @Update
    fun updateItems(vararg items: Item?)

    @Delete
    fun delete(item: Item)

    @Query("DELETE FROM item")
    fun clear()
}